﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Windows.Media.Imaging;

namespace SLGameEngine
{
    public class Utils
    {
        public static BitmapImage LoadImage(string imgResource)
        {
            Uri uri = new Uri(imgResource, UriKind.Relative);
            return (new System.Windows.Media.Imaging.BitmapImage(uri));
        }

        public static string GetImageFileName(Image img)
        {
            if (img.Source == null)
                return null;

            return ((BitmapImage)img.Source).UriSource.OriginalString;
        }

        public static string GetAnimationType(Enums.AnimationType type)
        {
            switch (type)
            {
                case Enums.AnimationType.Attack:
                    return "Attack";
                case Enums.AnimationType.Death:
                    return "Death";
                case Enums.AnimationType.End:
                    return "End";
                case Enums.AnimationType.Fly:
                    return "Fly";
                case Enums.AnimationType.Hit:
                    return "Hit";
                case Enums.AnimationType.Idle:
                    return "Idle";
                case Enums.AnimationType.Run:
                    return "Run";
                case Enums.AnimationType.Walk:
                    return "Walk";
            }

            return "Unknown";
        }

        public static string GetDirection(Enums.Direction direction)
        {
            switch (direction)
            {
                case Enums.Direction.North:
                    return "North";
                case Enums.Direction.South:
                    return "South";
                case Enums.Direction.West:
                    return "West";
                case Enums.Direction.East:
                    return "East";
                case Enums.Direction.NW:
                    return "NW";
                case Enums.Direction.NE:
                    return "NE";
                case Enums.Direction.SW:
                    return "SW";
                case Enums.Direction.SE:
                    return "SE";
            }

            return "Unknown";
        }

        public static Enums.Direction GetDirection(string direction)
        {
            switch (direction)
            {
                case "north":
                    return Enums.Direction.North;
                case "ne":
                    return Enums.Direction.NE;
                case "east":
                    return Enums.Direction.East;
                case "se":
                    return Enums.Direction.SE;
                case "south":
                    return Enums.Direction.South;
                case "sw":
                    return Enums.Direction.SW;
                case "west":
                    return Enums.Direction.West;
                case "nw":
                    return Enums.Direction.NW;
            }

            return Enums.Direction.South;
        }

        public static Enums.AnimationType GetAnimationType(string type)
        {
            switch (type)
            {
                case "attack":
                    return Enums.AnimationType.Attack;
                case "hit":
                    return Enums.AnimationType.Hit;
                case "death":
                    return Enums.AnimationType.Death;
                case "fly":
                    return Enums.AnimationType.Fly;
                case "walk":
                    return Enums.AnimationType.Walk;
            }

            return Enums.AnimationType.Unknown;
        }

      
    }
}
